﻿Public Class clsProdXbInfo
    Public Function getProdXbInfoByProdId(prod_id As String) As DataTable
        Dim szSql As String = "SELECT * FROM sf.b_prod_xb_info WHERE factory_id=? and prod_id = ? "
        Return DBacs.ExecuteSql(szSql, -1, "TS", prod_id)
    End Function

    Public Function setStatus(prodID As String, reason As String, content As String, result As String, deviation As String, deviation_size As String, oper As String, is_status As Integer, xb_no As Integer) As Integer
        Dim szSql As String
        Dim rtn As Integer
        DBacs.BeginTransaction()
        Try
            szSql = String.Empty
            szSql &= "INSERT INTO sf.b_prod_xb_info(factory_id, prod_id,reason, content, result, deviation, deviation_size, operator, update_time,xb_no) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, (SELECT CURRENT_TIMESTAMP(6)), ?); "
            rtn = DBacs.ExecuteUpdateSql(szSql, -1, "TS", prodID, reason, content, result, deviation, deviation_size, oper, xb_no)
            szSql = "select * from sf.b_lh_ck where prod_id = ? "
            Dim dtlhck As DataTable = DBacs.ExecuteSql(szSql, -1, prodID)
            If dtlhck.Rows.Count = 0 Then
                szSql = String.Empty
                szSql &= "update sf.b_prod_info set update_time = (SELECT CURRENT_TIMESTAMP(6)),"
                szSql &= " xiu_bian_dt = (SELECT CURRENT_TIMESTAMP(6)), xiu_bian_ope = ? "
                If is_status = 0 Then
                    szSql &= " ,status = ? "
                End If
                szSql &= " where factory_id = ? and prod_id = ? "
                If is_status = 0 Then
                    rtn = DBacs.ExecuteUpdateSql(szSql, -1, oper, "8", "TS", prodID)
                Else
                    rtn = DBacs.ExecuteUpdateSql(szSql, -1, oper, "TS", prodID)
                End If
            End If
            DBacs.CommitTransaction()
        Catch ex As Exception
            rtn = -2
            DBacs.RollbackTransaction()
        End Try
        Return rtn
    End Function

End Class
